#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <time.h>
#define N 10
#define M 8
typedef struct card
{
    char suit[N];
    char face[M];
}CARD;
void Initialize(CARD poker[52])
{
    strcpy(poker[0].suit,"Spades");
    strcpy(poker[0].face,"A");
    strcpy(poker[1].suit,"Spades");
    strcpy(poker[1].face,"2");
    strcpy(poker[2].suit,"Spades");
    strcpy(poker[2].face,"3");
    strcpy(poker[3].suit,"Spades");
    strcpy(poker[3].face,"4");
    strcpy(poker[4].suit,"Spades");
    strcpy(poker[4].face,"5");
    strcpy(poker[5].suit,"Spades");
    strcpy(poker[5].face,"6");
    strcpy(poker[6].suit,"Spades");
    strcpy(poker[6].face,"7");
    strcpy(poker[7].suit,"Spades");
    strcpy(poker[7].face,"8");
    strcpy(poker[8].suit,"Spades");
    strcpy(poker[8].face,"9");
    strcpy(poker[9].suit,"Spades");
    strcpy(poker[9].face,"10");
    strcpy(poker[10].suit,"Spades");
    strcpy(poker[10].face,"Jack");
    strcpy(poker[11].suit,"Spades");
    strcpy(poker[11].face,"Queen");
    strcpy(poker[12].suit,"Spades");
    strcpy(poker[12].face,"King");
    strcpy(poker[13].suit,"Hearts");
    strcpy(poker[13].face,"A");
    strcpy(poker[14].suit,"Hearts");
    strcpy(poker[14].face,"2");
    strcpy(poker[15].suit,"Hearts");
    strcpy(poker[15].face,"3");
    strcpy(poker[16].suit,"Hearts");
    strcpy(poker[16].face,"4");
    strcpy(poker[17].suit,"Hearts");
    strcpy(poker[17].face,"5");
    strcpy(poker[18].suit,"Hearts");
    strcpy(poker[18].face,"6");
    strcpy(poker[19].suit,"Hearts");
    strcpy(poker[19].face,"7");
    strcpy(poker[20].suit,"Hearts");
    strcpy(poker[20].face,"8");
    strcpy(poker[21].suit,"Hearts");
    strcpy(poker[21].face,"9");
    strcpy(poker[22].suit,"Hearts");
    strcpy(poker[22].face,"10");
    strcpy(poker[23].suit,"Hearts");
    strcpy(poker[23].face,"Jack");
    strcpy(poker[24].suit,"Hearts");
    strcpy(poker[24].face,"Queen");
    strcpy(poker[25].suit,"Hearts");
    strcpy(poker[25].face,"King");
    strcpy(poker[26].suit,"Clubs");
    strcpy(poker[26].face,"A");
    strcpy(poker[27].suit,"Clubs");
    strcpy(poker[27].face,"2");
    strcpy(poker[28].suit,"Clubs");
    strcpy(poker[28].face,"3");
    strcpy(poker[29].suit,"Clubs");
    strcpy(poker[29].face,"4");
    strcpy(poker[30].suit,"Clubs");
    strcpy(poker[30].face,"5");
    strcpy(poker[31].suit,"Clubs");
    strcpy(poker[31].face,"6");
    strcpy(poker[32].suit,"Clubs");
    strcpy(poker[32].face,"7");
    strcpy(poker[33].suit,"Clubs");
    strcpy(poker[33].face,"8");
    strcpy(poker[34].suit,"Clubs");
    strcpy(poker[34].face,"9");
    strcpy(poker[35].suit,"Clubs");
    strcpy(poker[35].face,"10");
    strcpy(poker[36].suit,"Clubs");
    strcpy(poker[36].face,"Jack");
    strcpy(poker[37].suit,"Clubs");
    strcpy(poker[37].face,"Queen");
    strcpy(poker[38].suit,"Clubs");
    strcpy(poker[38].face,"King");
    strcpy(poker[39].suit,"Clubs");
    strcpy(poker[39].face,"A");
    strcpy(poker[40].suit,"Diamonds");
    strcpy(poker[40].face,"2");
    strcpy(poker[41].suit,"Diamonds");
    strcpy(poker[41].face,"3");
    strcpy(poker[42].suit,"Diamonds");
    strcpy(poker[42].face,"4");
    strcpy(poker[43].suit,"Diamonds");
    strcpy(poker[43].face,"5");
    strcpy(poker[44].suit,"Diamonds");
    strcpy(poker[44].face,"6");
    strcpy(poker[45].suit,"Diamonds");
    strcpy(poker[45].face,"7");
    strcpy(poker[46].suit,"Diamonds");
    strcpy(poker[46].face,"8");
    strcpy(poker[47].suit,"Diamonds");
    strcpy(poker[47].face,"9");
    strcpy(poker[48].suit,"Diamonds");
    strcpy(poker[48].face,"10");
    strcpy(poker[49].suit,"Diamonds");
    strcpy(poker[49].face,"Jack");
    strcpy(poker[50].suit,"Diamonds");
    strcpy(poker[50].face,"Queen");
    strcpy(poker[51].suit,"Diamonds");
    strcpy(poker[51].face,"King");
}
void WashCards(CARD poker[52])
{
    srand(time(NULL));
    int i;
    CARD temp;
    int num;
    for(i=0;i<52;i++)
    {
        num=rand()%52;
        temp=poker[num];
        poker[num]=poker[i];
        poker[i]=temp;
    }
}
void DealCards(CARD poker[52],int n)
{
    int i,j;
    for(j=0;j<n;j++)
    {
        int k=0;
        for(i=j;i<52;i+=n)
        {
            k++;
            printf("the No.%d player's No.%d card is %s %s.\n",j+1,k,poker[i].suit,poker[i].face);
        }
    }
}
void main()
{
    char judge;
    CARD poker[52];
    CARD *pcard=poker;
    Initialize(poker);
    RESTART:printf("The poker cards are washing...\n");
    getchar();
    WashCards(poker);
    int player;
    printf("please input how many players:");
    scanf("%d",&player);
    DealCards(poker,player);
    printf("Do you want to deal again?(Y/N):");
    scanf(" %c",&judge);
    getchar();
    if(judge=='Y')
    {
        goto RESTART;
    }
}
